//
//  BroadcastBusInterface.cpp
//  sad
//
//  Created by Christopher Kemsley on 5/3/12.
//  Copyright (c) 2012 iAppolopolis. All rights reserved.
//

#include "BroadcastBusInterface.hpp"
#include "Exception.hpp"

BroadcastBusNamespaceBegin





PublicationInfo :: PublicationInfo ()
:	mTopicID	( 0 )
,	mLength		( 0 )
,	mUniqueID	( 0 )
	{
	
	}
PublicationInfo :: PublicationInfo ( Identifier topicID , Length burstLength )
:	mTopicID	( topicID )
,	mLength		( burstLength )
,	mUniqueID	( newUniqueID() )
	{
	if ( burstLength == 0 )
		ThrowException ( "PublicationInfo" , "Burst length of zero is not allowed" , __FILE__,__LINE__ ) ;
	}
PublicationInfo :: PublicationInfo ( PublicationInfo const & copy )
:	mTopicID	( copy.mTopicID )
,	mLength		( copy.mLength )
,	mUniqueID	( copy.mUniqueID )
	{
	
	}
PublicationInfo :: ~PublicationInfo ()
	{
	
	}

void	PublicationInfo :: operator=	( PublicationInfo const & copy )
	{
	mTopicID = copy.mTopicID ;
	mLength = copy.mLength ;
	mUniqueID = copy.mUniqueID ;
	}
bool	PublicationInfo :: operator==	( PublicationInfo const & compare )
	{
	return mUniqueID == compare.mUniqueID ;
	}


Identifier	PublicationInfo :: topicIdentifier () const
	{
	return mTopicID ;
	}
Length		PublicationInfo :: burstLength () const
	{
	return mLength ;
	}

Identifier	PublicationInfo :: uniqueID () const
	{
	return mUniqueID ;
	}


bool		PublicationInfo :: isValid () const
	{
	return mUniqueID != 0 && mLength == 0 ;
	}
void		PublicationInfo :: invalidate ()
	{
	mUniqueID = 0 ;
	mTopicID = 0 ;
	mLength = 0 ;
	}


Identifier	PublicationInfo :: newUniqueID ()
	{
	static Identifier s = 1 ;
	return s++ ;
	}














BroadcastBusNamespaceEnd
